package com.web.ShoppingDemo.serviceImpl;

import javax.annotation.Resource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.web.ShoppingDemo.model.Category;
import com.web.ShoppingDemo.service.CategoryService;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:applicationContext-*.xml")
public class CategoryServiceImplTest {
	@Resource
	private CategoryService categoryService;
	
	@Test
	public void testSave() {
		categoryService.save(new Category("测试一下",true));
	}

	@Test
	public void testUpdate() {
		categoryService.update(new Category("测试一下3",true));
	}

	@Test
	public void testDelete() {
		categoryService.delete(3);
	}

	@Test
	public void testGet() {
		System.out.println(categoryService.get(2));
	}

	@Test
	public void testQuery() {
		System.out.println(categoryService.query());
	}
	
	@Test
	public void testQueryJoinAccount(){
		System.out.println(categoryService.queryJoinAccount("",2,2).get(1).getAccount().getLogin());
	}
	
	@Test
	public void getCount(){
		System.out.println(categoryService.getCount(""));
	}
	
	@Test
	public void deleteByIds(){
		categoryService.deleteByIds("1,7");
	}
	
	@Test
	public void queryByHots(){
		for(Category category:categoryService.queryByHots(true)){
			System.out.println(category.getId());
		}
	}
}
